package singleton;

/**
 * 双检锁/双重校验锁
 *
 * @author 若雨成霜
 */
public class SingletonType4 {
    private volatile static SingletonType4 singleton;

    private SingletonType4() {
    }

    public static SingletonType4 getSingleton() {
        if (singleton == null) {
            synchronized (SingletonType4.class) {
                if (singleton == null) {
                    singleton = new SingletonType4();
                }
            }
        }
        return singleton;
    }
}
